import request from '@/router/axios';
import { baseUrl } from '@/config/env';

/* 获取公告类别*/ 
export const getNoticeCategory = (itemCode) => request({
    url: baseUrl + '/data-items/' + itemCode + '/detail/tree?keyword=' ,
    method: 'get',
}); 

/* 获取公告来源*/ 
export const notificationSource = (itemCode) => request({
    url: baseUrl + '/data-items/' + itemCode + '/detail/tree' ,
    method: 'get',
}); 

/* 获取轮播公告数*/ 
export const notificationInfo = () => request({
    url: baseUrl + '/app/notification/config/info' ,
    method: 'get',
});

/* 更新通知公告 轮播数量*/ 
export const notificationAmount = (num) => request({
    url: baseUrl + '/app/notification/config/slideshow-amount/' + num ,
    method: 'patch',
});

/* 获取公告 */
export const getNotice = (params) => request({
    url: baseUrl + '/app/notification',
    method: 'get',
    params: params
});

/* 获取手机公告数据 和 轮播联动的 */
export const getMobileSlide = () => request({
    url: baseUrl + '/app/notification/slideshow',
    method: 'get'
});

/* 获取公告 */
export const getNoticeDetail = (id) => request({
    url: baseUrl + '/app/notification/' + id,
    method: 'get'
});

/* 新增 */
export const addNotice = (obj) => request({
    url: baseUrl + '/app/notification',
    method: 'post',
    data: obj
}); 

/* 编辑 */
export const modifyNotice = (id,obj) => request({
    url: baseUrl + '/app/notification/' + id,
    method: 'put',
    data: obj
}); 

/* 删除 */
export const deleteNotice = (ids) => request({
    url: baseUrl + '/app/notification/' + ids,
    method: 'delete',
});

/*修改状态*/
export const setPublished = (id, status) => request({
    url: baseUrl + `/app/notification/${id}/set-published/${status}`,
    method: 'patch'
});

// 置顶
export const setTop = (id, mark) => request({
    url: baseUrl + `/app/notification/${id}/set-top/${mark}`,
    method: 'patch'
});